package com.lxd.sunso.product;


import com.lxd.sunso.product.netty.server.socket.NettyServer;
import com.lxd.sunso.product.netty.server.websocket.MyWebServer;
import com.lxd.sunso.product.service.MachineService;
import org.mybatis.spring.annotation.MapperScan;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableAsync;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;


@MapperScan("com.lxd.sunso.product.dao")
@SpringBootApplication
@EnableAsync
public class SunsoProductApplication implements CommandLineRunner {

    private Logger logger = LoggerFactory.getLogger(SunsoProductApplication.class);

    @Autowired
    private NettyServer nettyServer;

    @Autowired
    private MyWebServer myWebServer;

    @Autowired
    private MachineService machineService;

    //默认线程池
    private static ExecutorService executorService = Executors.newFixedThreadPool(2);

    public static void main(String[] args) {
        SpringApplication.run(SunsoProductApplication.class, args);
    }

    @Override
    public void run(String... args) throws Exception {
        machineService.setunOnline();
        myWebServer.start();
        nettyServer.start();
    }
}
